﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mywithdraw.aspx.cs" Inherits="SF.Ucenter.mycenterusers.mywithdraw" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="format-detection" content="telephone=no"/>
    <link rel="stylesheet" type="text/css" href="css/mywithdraw.css" media="all"/>
    <script src="js/jquery.js"></script>
    <title>我的佣金</title>
    <script type="text/javascript">
        //初始化数据
        $(function () {
            $.get("/tools/centerusers_ajax.ashx", { action: "get_mywithdraw_msg" }, function (res) {
                var temp = res.split("^");
                var strs = temp[1].split("_");
                $(".bro-spare .number-big").text("￥" + strs[0]);
                $(".bro-spare .field-2 big").text("￥" + strs[1]);
                $(".maneylist-li .money-number").text("￥" + strs[2]);
                $($(".money-source li .money-source-value")[0]).text("￥" + strs[3]);
                $($(".money-source li .money-source-value")[1]).text("￥" + strs[4]);
                $($(".money-source li .money-source-value")[2]).text("￥" + strs[5]);
            });
            var str = $($(".addr_box").children("span")[0]).text();
            if (str != "") {
                var temp = str.split("^");
                var strs = temp[1].split("_");
                $($(".addr_box").children("p")[0]).html("持卡人：" + strs[0] + "<span class='addr_tel'>手机号：" + strs[1] + "</span>");
                $($(".addr_box").children("p")[1]).text("卡号：" + strs[2]);
                $(".bro-extract-btn a").attr("id", strs[3]);
                $(".bro-extract-btn a").text("确认提现");
                $(".bro-extract-btn a").attr("href", "javascript:withdrawNow();");
                $(".u-addrbox").css("display", "block");
                $(".connerdiv").css("display", "block");
            }
        });

        //显示/隐藏下属
        function showlist(obj) {
            $(obj).parent().children(".money-source").toggle();
        }
        //确认提现操作
        function withdrawNow() {
            var id = $(".bro-extract-btn a").attr("id");
            if (id != null) {
                if (id.length > 1) {
                    var moneys = $(".connerbox dd").children("input").val();
                    var mymoneys = $(".bro-spare .number-big").text().split("￥");
                    if (parseFloat(moneys).toString() == "NaN") {
                        alert("请输入数字！");
                        return;
                    } else if (parseFloat(moneys) != 0 && parseFloat(moneys) > parseFloat(mymoneys[1])) {
                        alert("请输入有效金额！");
                        return;
                    }
                    if (parseFloat(moneys) <= 10) {
                        alert("提现金额不得低于10元！");
                        return;
                    }
                    $.get("/tools/centerusers_ajax.ashx", { action: "apply_withdraw", payid: id, money: moneys }, function (res) {
                        if (res == "true") {
                            alert("已申请提现！");
                            location.reload();
                        } else if (res == "false") {
                            alert("提现方式不存在！");
                        } else {
                            alert("网络繁忙，请稍后再试！");
                        }
                    });
                } else {
                    alert("请选择提现方式！");
                }
            }
        }
        //申请提现
        function showbox(obj) {
            var result = "";
            $.get("/tools/centerusers_ajax.ashx", { action: "get_withdraw_payway" }, function (res) {
                result = res;
                if (result.length < 1) {
                    $(".addr_box").html("<p>无提现方式，请点击选择！</p>");
                    $(".bro-extract-btn a").attr("id", "");
                } else {
                    var temp = result.split("^");
                    var strs = temp[1].split("_");
                    $($(".addr_box").children("p")[0]).html("持卡人：" + strs[0] + "<span class='addr_tel'>手机号：" + strs[1] + "</span>");
                    $($(".addr_box").children("p")[1]).text("卡号：" + strs[2]);
                    $(".bro-extract-btn a").attr("id", strs[3]);
                }
            });
            $(obj).text("确认提现");
            $(".bro-extract-btn a").attr("href", "javascript:withdrawNow();");
            $(".u-addrbox").css("display", "block");
            $(".connerdiv").css("display", "block");
        }
        //更换 提现方式
        function changeWay() {
            location.href = "payway.aspx";
        }
    </script>
</head>
<body>
    <div class="mask"></div>
    <!--topbar begin-->
    <div class="fixed tab-bar">        
            <section class="left-small">
                <a class="menu-icon" href="javascript:history.back();"><span></span></a>
            </section>
            <section class="middle tab-bar-section">
                <h1 class="title">我的佣金</h1>
            </section>
    </div>
    <!--topbar end-->
    <!--amount begin-->
    <div class="bro-spare">
        <p class="tip-txt"><i class="icon-money"></i>可提现佣金余额</p>
        <span class="number-big">￥0.00</span>
        <p class="field-2">已提现佣金总额：<big>￥0.00</big></p>
    </div>
    <!--amount end-->
    <!--list begin-->
    <ul class="maneylist" style="display: block;">
        <li class="maneylist-li">
            <a onclick="showlist(this);" class="a-personal">
                <i class="icon-money-circle"></i>
                <span class="text">已收货订单佣金</span>
                <span class="money-number">￥0.00</span>
                <i class="arrow"></i>
            </a>
            <!--count begin-->
            <div class="money-source" style="display: none;">
                <ul class="money-source-list">
                    <li class="money-source-li"><span class="money-source-label">一级会员：</span><span class="money-source-value">￥0.00</span></li>
                    <li class="money-source-li"><span class="money-source-label">二级会员：</span><span class="money-source-value">￥0.00</span></li>
                    <li class="money-source-li"><span class="money-source-label">三级会员：</span><span class="money-source-value">￥0.00</span></li>
                </ul>
            </div>
        </li>
    </ul>
    <!--list end-->
    
    <div class="u-addrbox userdiv" style="display:none;">
        <div class="addr_box" onclick="changeWay()">
            <span style="display:none;"><%=res %></span>
            <p>持卡人：<span class="addr_tel">手机号：</span></p>
            <p>卡号：</p>
        </div>
        <div class="addr_ope"></div>
    </div>
    <div class="connerdiv" style="display:none;">
        <dl class="connerbox">
            <dd><span class="form_hd">提现金额：</span><span class="ml80"></span><input id="money" runat="server" value="" class="text_input" type="text"/></dd>
        </dl>
    </div>
    <div class="bro-extract-btn">
        <a href="javascript:showbox(this);" class="button [radius round] red" >申请提现</a>
    </div>

</body>
</html>

